<!-- components/Btn.vue -->
<template>
  <div class="btn">
    <!-- 通过commit调用mutations里的方法 -->
    <button @click="this.$store.commit('addNum')">加一(mutations)</button>
    <!-- 通过dispatch调用actions里的方法 -->
    <button @click="this.$store.dispatch('reduceNumAction')">减一(actions)</button>
    <div></div>
    <button @click="addNum()">mapMutations加一</button>
    <button @click="reduceNumAction()">mapActions减一</button>
    <!-- <button @click="addNumAction()">mapActions加一</button> -->
  </div>
</template>


<script>
import { mapMutations ,mapActions} from 'vuex'
export default {
  methods: {
    ...mapMutations(['addNum']),
    ...mapActions(['reduceNumAction', 'addNumAction'])
  }
}
</script>